import java.util.Scanner;

/**
 * @author vivi
 * @description
 * @date 2024/4/23
 */
public class demo3 {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), m = scanner.nextInt();
        //a表示有几行，b表示有几列
        char[][] arr = new char[n+1][m+1]; //为什么+1 --> 下标从1开始

        //给矩阵赋值
        for(int i = 1; i <= n; i++)
        {
            char[] s = scanner.next().toCharArray();
            for(int j = 1; j <= m; j++)
            {
                arr[i][j] = s[j - 1];
            }
        }

        int[][] dp = new int[n + 1][m + 1];
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= m; j++)
            {
                int t = 0;
                if(arr[i][j] == 'l'){
                    t = 4;
                }else if(arr[i][j] == 'o'){
                    t = 3;
                }else if(arr[i][j] == 'v'){
                    t = 2;
                }else if(arr[i][j] == 'e'){
                    t = 1;
                }
                dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + t; //?
            }
        }
        System.out.println(dp[n][m]);

    }
}
